<?php

/**
 * Created by PhpStorm.
 * user: evan
 * Date: 16/8/18
 * Time: 下午2:50
 */
class Api extends MY_Www_Controller
{
    /**
     * http://www.shikee.dev/api/index
     * api_config
     * api.js
     */
    public function index()
    {
        $api_config = api_config();


        $data = array(
            'api_config' => $api_config,
        );

        $this->load->view('api/api/demo', $data);
    }
    
    
    public function error()
    {
    	require(APPPATH.'config/error.php');
    	echo '<table style="width:100%;" cellpadding="2" cellspacing="0" border="1" bordercolor="#000000"><tr><td style="width:15%;">code</td><td>message</td></tr>';
    	
    	foreach($error as $v){
    		echo '<tr><td>'.$v['code'].'</td><td>'.$v['msg'].'</td></tr>';
    	}
    	
    	echo '</table>';
    }


    /**
     * 获取指定模块或模块接口
     */
    public function get()
    {
        $module    = trim($this->input->get_post('module'));
        $interface = trim($this->input->get_post('interface'));

        $response = error(100004);

        do
        {
            if (empty($module))
            {
                $response = error(100006);
                break;
            }

            $api_config = api_config($module, $interface);

            $response['data'] = $api_config;

        } while(false);

        echo json_encode($response);
    }


    /**
     * 文件上传
     */
    public function file_upload()
    {

        $this->load->view('api/api/file_upload');
    }


    public function tt()
    {
        $this->load->library('pay/pay');
        $param = array
        (
            //'cid'      => $pay_channel,
            'cid'      => 1,
            'uid'      => 1,
            'amount'   => 1,
            'order_id' => 1,
            'op_type'  => PAY::op_type_request,
            'title'    => '用户充值',
            'descr'    => 'userrecharge',
            'pay_type' => 1,
            'client'   => 'android'
        );
        $pay_rs = $this->pay->factory($param);
    }


    public function test()
    {
        $this->load->model('common/Model_audit_log', 'f');
         $this->f->show_all_field();
    }


    public function test1()
    {
        header('Location:http://www.seedke.com');
        exit;


        $link = mysqli_connect('139.224.65.190', 'root', 'Mysql@123');
        mysqli_set_charset($link, 'utf8');
        mysqli_select_db($link, 'sk');


        $resource = mysqli_query($link, 'select * from sk_user where uid=30');
        $result = mysqli_fetch_array($resource);
        echo '<pre>';print_r($result);
    }
}